#include <iostream>

using namespace std;

const int total = 10;
int** tablero;
void initialize();// inicializa las celdas
void print(); // imprime el tablero
int count_neighbors(int i, int j); //
void iterate(); //simula un el siguiente estado.

void simulate_life(int count) {
    for(int i=0; i<count; i++) {
        print();
        //iterate();
    }
}

int main()
{
    cout << "Hello world!" << endl;
    tablero = new int* [total];

    for(int i=0; i<total;i++)
        tablero[i] = new int [total];

    for(int i=0; i<total;i++){
      for(int j=0; j<total;j++)
             tablero[i][j] = 1;
    }
    print();
    cout << count_neighbors(9,9) << endl;
    return 0;
}

void print(){
    for(int i=0; i<total;i++){
        for(int j=0; j<total;j++){
            if(tablero[i][j])
                cout << "*";
            else
                cout <<".";
        }
        cout << endl;
    }
}

int count_neighbors(int i,int j){
    int count = 0;
    if(i-1 >= 0){
        if(j-1>=0 && tablero[i-1][j-1])
            count++;
        if(tablero[i-1][j])
            count++;
        if(j+1 < total && tablero[i-1][j+1])
            count++;
    }
    if(j-1>=0 && tablero[i][j-1])
        count++;
    if(j+1 < total && tablero[i][j+1])
        count++;
    if(i+1 < total){
        if(j-1>=0 && tablero[i+1][j-1])
            count++;
        if(tablero[i+1][j])
            count++;
        if(j+1 < total && tablero[i+1][j+1])
            count++;
    }
    return count;
}
